#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef double db;
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+ch-'0'; ch=getchar(); }
	return x*f;
}
const int MAXN=1e6+10;
int n,dis[MAXN],head[MAXN],cnt;
bool vis[MAXN],vl[MAXN],vr[MAXN];
struct edge
{
	int v,next,val;
}e[MAXN*10];
void addedge(int x,int y,int z)
{
	e[++cnt]=(edge){y,head[x],z};
	head[x]=cnt;
	return;
}
void SPFA()
{
	queue<int>q;
	q.push(1);
	memset(dis,INF,sizeof(dis));
	dis[1]=0;
	vis[1]=true;
	while(!q.empty())
	{
		int u=q.front();q.pop();
		vis[u]=false;
		for(int i=head[u];i;i=e[i].next)
		{
			int v=e[i].v;
			if(dis[v]>dis[u]+e[i].val)
			{
				dis[v]=dis[u]+e[i].val;
				if(!vis[v])
				{
					vis[v]=true;
					q.push(v);
				}
			}
		}
	}
	return;
}
int main()
{
	n=read();
	for(int i=1;i<=n;++i)
	{
		int x=read();
		if(i+x>n)addedge(i,n+1,i+x-n);
		else addedge(i,i+x+1,0);
		for(int j=i+x+1;j<=n&&!vr[j];++j)vr[j]=true,addedge(j,j+1,1);
		for(int j=i+1;j<=i+x+1&&!vl[j];++j)vl[j]=true,addedge(j,j-1,1);
	}
	SPFA();
	printf("%d\n",dis[n+1]);
	return 0;
}
